<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class RoleRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' =>'unique:roles,name,'.$this->id.',id',
            'slug' =>'unique:roles,slug,'.$this->id.',id'
        ];
    }
    public function messages()
    {
        return [
            'name.unique' => '该角色名称已经被注册过了',
            'slug.unique' => '该key已经被注册过了'
        ];
    }
}
